package com.ajing.logextractor.extractor;


import com.ajing.logextractor.config.ExtractConfig;

public class ExtractorFactory {

    public static AbstractExtractor getExtractor(ExtractConfig extractConfig) {
        if (extractConfig == null) {
            return null;
        }
        if ("JSON".equalsIgnoreCase(extractConfig.getMode())) {
            return new JsonExtractor(extractConfig.getPattern(), extractConfig.getSub());
        } else if ("REGEX".equalsIgnoreCase(extractConfig.getMode())) {
            return new RegexExtractor(extractConfig.getPattern(), extractConfig.getSub());
        } else if ("JSON_FLAT".equalsIgnoreCase(extractConfig.getMode())) {
            return new JsonFlatExtractor(extractConfig.getPattern(), extractConfig.getSub());
        }
        return null;
    }
}
